package it.cums.core.model;

import java.beans.PropertyChangeListener;
import java.util.ArrayList;

public class Product{
	private ArrayList<PropertyChangeListener> listeners = new ArrayList<PropertyChangeListener>();
	private int id;
	private String name;
	private String manufacturer;
	private double purchasingPrice;
	private double salesPrice;
	private int iva;
	private int availableQuantity;
	private String notes;
	
	public Product() {
	}

	public int getId() {
		return id;
	}

	public void setId(int id) {
		this.id = id;
	}

	public void setName(String name) {
		this.name = name;
		notifyListeners();
	}

	public String getName() {
		return name;
	}

	public String getManufacturer() {
		return manufacturer;
	}

	public void setManufacturer(String manufacturer) {
		this.manufacturer = manufacturer;
	}

	public double getPurchasingPrice() {
		return purchasingPrice;
	}

	public void setPurchasingPrice(double purchasingPrice) {
		this.purchasingPrice = purchasingPrice;
	}
	
	public void setSalesPrice(double salesPrice) {
		this.salesPrice = salesPrice;
	}

	public double getSalesPrice() {
		return salesPrice;
	}

	public void setIva(int iva) {
		this.iva = iva;
	}

	public int getIva() {
		return iva;
	}

	public void setAvailableQuantity(int availableQuantity) {
		this.availableQuantity = availableQuantity;
	}

	public int getAvailableQuantity() {
		return availableQuantity;
	}

	public void setNotes(String notes) {
		this.notes = notes;
	}

	public String getNotes() {
		return notes;
	}

	public String toString() {
		return name;
	}
	
	private void notifyListeners() {
		for (PropertyChangeListener listener : listeners) {
			listener.propertyChange(null);
		}
	}
	
	public void setPropertyChangeListeners(ArrayList<PropertyChangeListener> listeners) {
		this.listeners = listeners;
	}
}
